package com.xc.pattern.strategy;

/**
 * @author xingchen
 * @description 优惠券
 * @create 2022-09-04 20:09
 */
public class VoucherActivity extends Strategy {

    /**
     * 传入优惠券
     */
    private double voucher;

    public VoucherActivity(double voucher) {
        this.voucher = voucher;
    }

    @Override
    public double computePrice(ProductOrder productOrder) {

        if (productOrder.getOldPrice() > voucher) {
            return productOrder.getOldPrice() - voucher;
        } else
            return 0;
    }

}
